Learn R Programming

foolbox (version 0.1.1)

[.foolbox_rewrite_spec: Provide list of rewrite transformations.

Description

This subscript operator is used together with rewrites to specify a sequence of transformations to apply to a new function we define.

Usage

# S3 method for foolbox_rewrite_spec
[(dummy, ...)

Arguments

dummy

The dummy-table rewrites. It is only here because it allows us to use subscripts as part of the domain-specific language.

...

A list of rewrite functions.

See Also

<.foolbox_pipe

rewrites

Examples

Run this code
# NOT RUN {
# This is a very simple inline function that require we
# provide the function body as it should be inserted.
# For a more detailed version, see the Tutorial vignette.
inline <- function(f, fn, body) {
   body <- substitute(body)
   rewrite(f) %>%
     rewrite_with(
         rewrite_callbacks() %>%
           add_call_callback(fn, function(expr, ...) body)
     )
}

g <- function(x) x**2
h <- rewrites[inline(g,y**2)] < function(y) y + g(y)
h

# }

Run the code above in your browser using DataLab